import TreeTraversal.TreeNode;

public class sortedArrayToBST22 {
    public TreeNode sortedArrayToBST(int[] nums) {
        return a(nums,0,nums.length-1);
    }
    public TreeNode a(int[] nums,int left,int right){
        if(left > right){
            return null;
        }
        int mid = (left + right) >>> 1;
        TreeNode root = new TreeNode(nums[mid]);
        root.left = a(nums,left,mid-1);
        root.right = a(nums,mid+1,right);
        return root;
    }
}
